# Arel-Bundock & Pelc: Buy-in for Buyouts

This README.md file includes replication instructions and codebooks for every data file.

## Replication instructions 

Install R packages:

```r
pkgs = c(
    "here",
    "ggplot2",
    "data.table",
    "ggokabeito",
    "modelsummary",
    "ipumsr",
    "marginaleffects",
    "patchwork",
    "tinytable",
    "survey"
)
install.packages(pkgs)
```

Run the scripts using the Makefile from the terminal (not an R session):

```sh
make
```

Alternatively, run each script sequentially from an R session:

```r
source("code/analysis_2021-05.R")
source("code/analysis_2021-08.R")
source("code/analysis_2022-08.R")
```

## R session info

```r
> sessionInfo()
R version 4.4.0 (2024-04-24)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 24.04 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.12.0 
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.12.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

time zone: America/New_York
tzcode source: system (glibc)

attached base packages:
[1] grid      stats     graphics  grDevices datasets  utils     methods  
[8] base     

other attached packages:
 [1] survey_4.4-2             survival_3.6-4           Matrix_1.7-0            
 [4] tinytable_0.3.0.2        patchwork_1.2.0          marginaleffects_0.20.1.1
 [7] ipumsr_0.7.2             modelsummary_2.1.0       ggokabeito_0.1.0        
[10] data.table_1.15.4        ggplot2_3.5.1            here_1.0.1              

loaded via a namespace (and not attached):
 [1] utf8_1.2.4        generics_0.1.3    bspm_0.5.7        lattice_0.22-6   
 [5] hms_1.1.3         digest_0.6.35     magrittr_2.0.3    fastmap_1.2.0    
 [9] rprojroot_2.0.4   DBI_1.2.2         fansi_1.0.6       scales_1.3.0     
[13] cli_3.6.2         mitools_2.4       rlang_1.1.3       munsell_0.5.1    
[17] splines_4.4.0     withr_3.0.0       tools_4.4.0       tzdb_0.4.0       
[21] dplyr_1.1.4       colorspace_2.1-0  zeallot_0.1.0     forcats_1.0.0    
[25] vctrs_0.6.5       R6_2.5.1          lifecycle_1.0.4   insight_0.19.11  
[29] pkgconfig_2.0.3   pillar_1.9.0      gtable_0.3.5      glue_1.7.0       
[33] Rcpp_1.0.12       haven_2.5.4       xfun_0.44         tibble_3.2.1     
[37] tidyselect_1.2.1  knitr_1.46        htmltools_0.5.8.1 tables_0.9.25    
[41] readr_2.1.5       compiler_4.4.0   
```

## Codebook

### 2021-05 dataset

- respondent: Unique identifier for each respondent (chr)
- age: Age of the respondent (num)
- age_census: Age category of the respondent (Factor with 3 levels: "18-34", "35-54", "55+")
- coal_counter: Respondent's main counter-argument regarding coal (chr)
- coal_loser: Group perceived to lose the most in coal-related issues (chr)
- coal_outcome: Respondent's rating of the coal buyout plan (int)
- coal_text: Respondent's additional comments on coal (chr)
- dictator_counter: Respondent's main counter-argument regarding dictators (chr)
- dictator_outcome: Respondent's rating of the dictator outcome (int)
- dictator_text: Respondent's additional comments on dictators (chr)
- education: Respondent's highest level of education completed (chr)
- education_census: Education level category of the respondent (Factor with 4 levels: "Less than high school graduate", "High school graduate", "Some college", "University completed or higher")
- gender: Gender of the respondent (Factor with 2 levels: "Man", "Woman")
- income: Respondent's income level (int)
- party: Respondent's political party affiliation (Factor with 3 levels: "Independent", "Democrat", "Republican")
- tax_counter: Respondent's main counter-argument regarding taxes (chr)
- tax_loser: Group perceived to lose the most in tax-related issues (chr)
- tax_outcome: Respondent's rating of the tax buyout plan (int)
- tax_text: Respondent's additional comments on taxes (chr)
- wts: Survey weights built from census data (num)

### 2021-08 dataset

- respondent: Unique identifier for each respondent (chr)
- age: Age of the respondent (num)
- age_census: Age category of the respondent (Factor with 3 levels: "18-34", "35-54", "55+")
- coal_compensate: Respondent's rating of coal worker compensation (int)
- coal_end: Respondent's rating of ending coal usage (int)
- coal_treatment: Respondent's preferred method to end coal usage (chr)
- college: Whether the respondent attended college (num)
- covid_check: Respondent's answer to a COVID-19 related question (chr)
- education: Respondent's highest level of education completed (chr)
- education_census: Education level category of the respondent (Factor with 4 levels: "Less than high school graduate", "High school graduate", "Some college", "University completed or higher")
- gender: Gender of the respondent (Factor with 2 levels: "Man", "Woman")
- income: Respondent's income level (Factor with 8 levels: "Less than USD 24,900", "USD 24,900-49,999", "USD 50,000-74,999", "USD 75,000-99,999", "USD 100,000-124,999", "USD 125,000-149,999",

### 2022-08 dataset

- respondent: Unique identifier for each respondent (chr)
- age: Age of the respondent (num)
- age_census: Age category of the respondent (Factor with 3 levels: "18-34", "35-54", "55+")
- approval_coal_4: Respondent's approval rating of the coal policy (num, 0-10 scale)
- approval_tax_4: Respondent's approval rating of the tax policy (num, 0-10 scale)
- counter_coal_1: Industries that block beneficial reforms do not deserve compensation from taxpayer dollars (int)
- counter_coal_2: Industries that harm society do not deserve compensation from taxpayer dollars (int)
- counter_coal_3: Compensating one industry will encourage other industries to block beneficial reforms in the future (int)
- counter_coal_4: By making large payments to industries, the government is interfering too much with the economy (int)
- counter_coal_5: This industry, and the jobs it represents, deserve government protection (int)
- counter_coal_6: Other reason (int)
- counter_coal_6_TEXT: Additional comments on the sixth counter-argument regarding coal (chr)
- counter_tax_1: Industries that block beneficial reforms do not deserve compensation from taxpayer dollars (int)
- counter_tax_2: Industries that harm society do not deserve compensation from taxpayer dollars (int)
- counter_tax_3: Compensating one industry will encourage other industries to block beneficial reforms in the future (int)
- counter_tax_4: By making large payments to industries, the government is interfering too much with the economy (int)
- counter_tax_5: This industry, and the jobs it represents, deserve government protection (int)
- counter_tax_6: Other reason (int)
- counter_tax_6_TEXT: Additional comments on the sixth counter-argument regarding taxes (chr)
- education: Respondent's highest level of education completed (chr)
- education_census: Education level category of the respondent (Factor with 4 levels: "Less than high school graduate", "High school graduate", "Some college", "University completed or higher")
- gender: Gender of the respondent (Factor with 2 levels: "Man", "Woman")
- ideo: Respondent's self-identified political ideology (chr)
- ideo7: Respondent's political ideology on a 7-point scale (num, 1=Very liberal, 7=Very conservative)
- ideology: Respondent's political ideology (chr)
- ideology_choose: Respondent's chosen political ideology (chr)
- moral_scale_1_1: It is never justified to cause harm or suffering to anyone (num, 0-10 scale)
- moral_scale_1_2: Some rules should never be broken, even if breaking them allows for a greater good (num, 0-10 scale)
- moral_scale_1_3: Some principles are universal: they do not depend on circumstances (num, 0-10 scale)
- moral_scale_1_4: A person’s life is sacred, and killing is always wrong (num, 0-10 scale)
- moral_scale_1_5: If causing harm or suffering to a person makes it possible to achieve greater good for a greater number of people, then it is justifiable (num, 0-10 scale)
- moral_scale_1_6: There are circumstances that justify breaking some rules—especially when breaking them enables achieving a greater good (num, 0-10 scale)
- moral_scale_1_7: Sometimes the ends justify the means (num, 0-10 scale)
- moral_scale_1_8: If sacrificing one person means saving many more, then it is permitted (num, 0-10 scale)
- moral_scale_2_1: It is never justified to cause harm or suffering to anyone (num, 0-10 scale)
- moral_scale_2_2: Some rules should never be broken, even if breaking them allows for a greater good (num, 0-10 scale)
- moral_scale_2_3: Some principles are universal: they do not depend on circumstances (num, 0-10 scale)
- moral_scale_2_4: A person’s life is sacred, and killing is always wrong (num, 0-10 scale)
- moral_scale_2_5: If causing harm or suffering to a person makes it possible to achieve greater good for a greater number of people, then it is justifiable (num, 0-10 scale)
- moral_scale_2_6: There are circumstances that justify breaking some rules—especially when breaking them enables achieving a greater good (num, 0-10 scale)
- moral_scale_2_7: Sometimes the ends justify the means (num, 0-10 scale)
- moral_scale_2_8: If sacrificing one person means saving many more, then it is permitted (num, 0-10 scale)
- party: Respondent's political party affiliation (Factor with 3 levels: "Independent", "Democrat", "Republican")
- pid_dem: Respondent's identification with the Democratic Party (chr)
- pid_ind: Respondent's identification with independents (chr)
- pid_order: Respondent's order of party identification (chr)
- pid_rep: Respondent's identification with the Republican Party (chr)
- pid7: Respondent's party identification on a 7-point scale (num, 1=Strong Democrat, 7=Strong Republican)
- reneging_coal_1: Respondent's rating on reneging coal policy, first item (num)
- reneging_tax_1: Respondent's rating on reneging tax policy, first item (num)
- vignette_coal_1: Respondent's rating on coal vignette, first item (num)
- vignette_tax_1: Respondent's rating on tax vignette, first item (num)
- wts: Survey weights built from census data (num)

